package com.lenovo.spider.component;

import com.lenovo.spider.common.spi.ServiceInterface;
import com.lenovo.spider.domain.Task;

/**
 * @author <a href="mailto:liuhan3@lenovo.com">HanL(liuhan3)</a>
 * on 2018/4/11 21:07
 */
public interface TaskProcess {

    boolean support(Task task);

    Task handle(Task task) throws Exception;

    default Task process(Task task) {
        try {
            return handle(task);
        } catch (Exception e) {
            return task.error(e);
        }
    }


    @ServiceInterface
    interface Downloader extends TaskProcess {

        enum Type {
            HTTP, WEBDRIVER;
        }
    }

    @ServiceInterface
    interface PreDownloaderInterceptor extends TaskProcess {

    }

    @ServiceInterface
    interface AfterDownloaderInterceptor extends TaskProcess {}

    @ServiceInterface
    interface PageParser extends TaskProcess {
    }

    @ServiceInterface
    interface Pipeline extends TaskProcess {
    }

    @ServiceInterface
    interface ExceptionHandler extends TaskProcess {
    }

}
